so ive been trying to do an nft collection by a video from youtube ( i dont know nothing in coding ) and it keep giving me this error:
' error:ReferenceError: upload is not defined error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined '
How can i resolve it?
I had a previous error that i resolved by installing npm i node-fetch@2.6.1
Anyways, know i have this one and just cant go anyfurther,
Would appreciate any help, THANK YOU
const fetch = require('node-fetch');
const path = require("path");
const basePath = process.cwd();
const fs = require("fs");
fs.readdirSync(`${basePath}/build/images`).forEach(File => {
const formData = new FormData();
const fileStream = fs.createReadStream(`${basePath}/build/images/${File}`);
formData.append('file',fileStream);
let url = '';
let options = {
method: 'POST',
headers: {
Authorization: '',
},
body: formData
};
options.body = formData;
fetch(url, options)
.then((res) => res.json())
.then((json) => {
const filename = path.parse(json.file_name).name;
let rawdata = fs.readFileSync(`${basePath}/build/json/${filename}.json`);
let metadata = JSON.parse(rawdata);
metadata.file_url = json.ipfs_url;
fs.writeFileSync(`${basePath}/build/json/${filename}.json`,
JSON.stringify(metadata, null, 2));
console.log(`${json.file_name} uploaded & ${upload}.json
updated!`);
})
.catch((err) => console.error('error:' + err));
});```